//------------Sonic CD BossArm Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 53: TYPE_BOSSARM

// Function declarations
#function BossArm_Function69

function BossArm_Function69
	ArrayPos0=Object.Value0
	Object.XPos=Object[ArrayPos0].XPos
	Object.XPos-=2359296
	Object.XPos+=Object.Value6
	Object.YPos=Object[ArrayPos0].YPos
	temp1=1
	GetBit(temp0,Object.Value4,7)
	if temp0==0
		if object[currentPlayer].YPos<Object.YPos
			if Object.Value7>-524288
				Object.Value7-=65536
			endif
			temp1=0
		endif
	endif
	if temp1==1
		if Object.Value7<524288
			Object.Value7+=65536
		endif
	endif
	Object.YPos+=Object.Value7
endfunction


event ObjectMain
	switch Object.State
	case 0
		Object.State=1
		CallFunction(BossArm_Function69)
		break
	case 1
		CallFunction(BossArm_Function69)
		break
	case 2
		Object.Value2-=1568
		Object.Value5+=4640
		Object.XPos+=Object.Value2
		Object.YPos+=Object.Value5
		Object.Value3++
		if Object.Value3==7
			Object.Value3=0
			CreateTempObject(TypeName[Explosion],0,Object.XPos,Object.YPos)
			PlaySfx(22,0)
		endif
		if Object.OutOfBounds==1
			Object.Type=TypeName[BlankObject]
			Object.Priority=0
		endif
		break
	case 3
		if Object.Value6>0
			Object.Value6-=32768
		endif
		CallFunction(BossArm_Function69)
		break
	case 4
		if Object.Value6<1048576
			Object.Value6+=32768
		endif
		CallFunction(BossArm_Function69)
		break
	case 5
		if Object.Value6<524288
			Object.Value6+=32768
		else
			Object.Frame=1
		endif
		ArrayPos0=Object.Value0
		Object.XPos=Object[ArrayPos0].XPos
		Object.XPos-=2359296
		Object.XPos+=Object.Value6
		if Object.Value7<524288
			Object.Value7+=65536
		endif
		Object.YPos=Object[ArrayPos0].YPos
		Object.YPos+=Object.Value7
		break

	endswitch
endevent


event ObjectDraw
	DrawSprite(3)
	DrawSprite(0)
endevent


event ObjectStartup
	LoadSpriteSheet("RRZ/Objects.gif")
	SpriteFrame(-15,-8,32,16,165,1)
	SpriteFrame(-6,-8,24,16,198,1)
	SpriteFrame(2,-8,16,16,148,18)
	SpriteFrame(9,-8,24,16,165,18)
endevent

event RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endevent
